Skip to content

Restore the previous autograd setting#49

Open
martenlienen wants to merge 1 commit into
jeanfeydy:mainfrom
martenlienen:autograd
Open

Restore the previous autograd setting#49
martenlienen wants to merge 1 commit into
jeanfeydy:mainfrom
martenlienen:autograd

Conversation

@martenlienen

Copy link
Copy Markdown

Indiscriminately enabling autograd at the end of the loop also enables it when the user
had explicitly disabled it before. This is a common occurrence when the loss is computed
over a validation set.

In my application this would stop the training with an out of memory error because autograd on the validation data quickly exhausts memory while it is fine in the training loop (sequential data with validation on full sequences but training on subsequences).

Indiscriminately enabling autograd at the end of the loop also enables it when the user
had explicitly disabled it before. This is a common occurrence when the loss is computed
over a validation set.
@caotians1

Copy link
Copy Markdown

I just had this bug causing validation to hang when used with DistributedDataParallel. DistributedDataParallel checks torch.is_grad_enabled() when determining whether to perform synchronization before forward pass. Geomloss turns grad_enabled on after the first iteration, causing threads to hang waiting for synchronization.

jeanfeydy added a commit that referenced this pull request Jun 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants